<template>
  <div>
    <el-dialog title="详细信息" :visible.sync="dialogVisible" class="dialog">
      <el-descriptions direction="vertical" :column="2" border>
        <el-descriptions-item label="订单编号">{{
          info.orderNo
          }}</el-descriptions-item>
        <el-descriptions-item label="提现金额">{{
          info.amount
          }}(等于{{ Number(info.amount / rate).toFixed(2) }}u)</el-descriptions-item>

        <!-- <el-descriptions-item v-if="info.type == 'usdt'" label="提币地址(TRC20)">{{
          info.accountInfo.trc20Address
        }}</el-descriptions-item>
        <el-descriptions-item v-if="info.type == 'rmb'" label="开户行">{{
          info.accountInfo.bankName
        }}</el-descriptions-item>
        <el-descriptions-item v-if="info.type == 'rmb'" label="银行账号">{{
          info.accountInfo.accountNumber
        }}</el-descriptions-item>
        <el-descriptions-item v-if="info.type == 'rmb'" label="持卡人姓名">{{
          info.accountInfo.name
        }}</el-descriptions-item> -->
        <el-descriptions-item label="开户行">{{
          info.bankOfDeposit
        }}</el-descriptions-item>
        <el-descriptions-item label="申请时间">{{
          info.createTime
          }}</el-descriptions-item>

        <el-descriptions-item label="用户id">{{
          info.userId
          }}</el-descriptions-item>
        <el-descriptions-item label="提现地址">{{
          info.address
          }}</el-descriptions-item>
        <el-descriptions-item label="提现方式">{{
          info.type
          }}</el-descriptions-item>
        <el-descriptions-item v-if="info.status == 'applying'" label="审核">
          <el-select v-model="vo.status" placeholder="请选择">
            <el-option label="审核通过" value="approved" />
            <el-option label="审核驳回" value="reject" />
          </el-select>
        </el-descriptions-item>
        <el-descriptions-item v-if="vo.status == 'reject'" label="驳回原因">
          <el-input v-model="vo.reason" type="textarea" placeholder="请输入驳回原因" />
        </el-descriptions-item>
        <el-descriptions-item v-if="info.status != 'applying'" label="审核">
          {{ setStateTxt(info.status) }}
        </el-descriptions-item>
      </el-descriptions>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>
<script>
import { _isMobile } from '@/utils/index'
import { approval ,getRate} from '@/api/table'
export default {
  data() {
    return {
      dialogVisible: false,
      info: {},
      isMobile: _isMobile,
      imageList: [],
      videoList: [],
      video: null,
      videoStatae: false,
      rate:1,
      vo: {
        status: '',
        reason: ''
      }
    }
  },

  methods: {
    setStateTxt(index) {
      let str = ''
      switch (index) {
        case 'applying':
          str = '申请中'
          break
        case 'approved':
          str = '审核通过'
          break
        case 'reject':
          str = '审核驳回'
          break
      }
      return str
    },
    async getRateAmount(){
     const res = await getRate()
     this.rate = res.data
     console.log(res)
    },
    show(e) {
      console.log(e)
      const data = JSON.parse(JSON.stringify(e))
      this.getRateAmount()
      this.vo.status = ''
      this.dialogVisible = true
      // data.rmbRate = (Number(data.rmbRate) + 0.02).toFixed(2)
      this.info = data
      console.log(this.info.rmbRate)
    },
    async confirm() {
      if (this.vo.status) {
        await approval({ id: this.info.id, status: this.vo.status, reason: this.vo.reason })
        this.$parent.fetchData()
        this.dialogVisible = false
      } else {
        this.dialogVisible = false
      }
    }
  }
}
</script>
